package com.study.zgw.juc;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
@Slf4j
public class Future {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<Integer>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                log.debug("running-----");
                Thread.sleep(1000);
                return 2;
            }
        });

        Thread t = new Thread(futureTask,"t1");
        t.start();

        log.debug("{}",futureTask.get());
    }

}
